<%@page import="java.text.SimpleDateFormat"%>
<%@page import="com.iflysse.bbs.model.NewsInfo"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="../base.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link style="text/css" rel="stylesheet" href="css/style.css">
<script type="text/javascript">
	$(function(){
		$("a.delete").click(function(){
			if(confirm("确认删除该记录吗？")){
				return true;
			}
			return false;
		});
	});
</script>
</head>
<body>
	<div style="width: 400px; margin: 0 auto;">

		<div id="head" style="text-align: left;">
			<a href="pages/personal/addnew.jsp">发布信息</a>
		</div>

		<div id="query">
			<form action="pages/personal/newslist_handler.jsp" method="post">
				<input type="text" name="qtitle"
					value="<%=request.getParameter("qtitle") == null ? "" : request
					.getParameter("title").toString()%>"
					style="height: 20px; width: 200px;">&nbsp;&nbsp;&nbsp; <input
					type="submit" value="查询">
			</form>
		</div>

		<div id="maindata">
			<table width="350px"
				style="border-collapse: collapse; text-align: center; margin: 0 auto; border: solid 1px gray;">
				<tr>
					<th class="data">标题</th>
					<th class="data">时间</th>
					<th class="data">操作</th>
				</tr>
				<%
					List<NewsInfo> list = null;
					if (request.getAttribute("newsData") != null) {
						list = (List<NewsInfo>) request.getAttribute("newsData");
					}
				%>

				<%
					if (list == null || list.size() == 0) {
						out.print("<tr><td class='data' colspan='3'>暂无数据信息</td></tr>");
					} else {
						SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
						for (NewsInfo news : list) {
				%>
				<tr>
					<td class="data"><a
						href="pages/view_handler.jsp?newsid=<%=news.getId()%>"
						target="_blank"><%=news.getTitle()%> </a></td>
					<td class="data"><%=sdf.format(news.getDate())%></td>
					<td class="data">
					<a class="delete" href="pages/personal/deletenews_handler.jsp?newsid=<%=news.getId()%>">删除</a>
					&nbsp;<a href="pages/personal/editnews_handler.jsp?newsid=<%=news.getId()%>">编辑</a>
					</td>
				</tr>
				<%
					}
					}
				%>
			</table>
		</div>
	</div>
</body>
</html>